/*
 * @Author      : ZhouQiJun
 * @Date        : 2025-08-09 14:53:07
 * @LastEditors : ZhouQiJun
 * @LastEditTime: 2025-08-09 15:49:12
 * @Description :
 */
import type { GisRef } from '@ol/define'
import { isNil } from 'es-toolkit'

import OlLayerFactory from './OlLayerFactory'

export default function useLayerFactory(gis: GisRef) {
  if (isNil(gis)) return null
  let factory = gis.cache['ol.ref.layer-factory'] as OlLayerFactory
  if (isNil(factory)) {
    factory = gis.cache['ol.ref.layer-factory'] = new OlLayerFactory(gis)
  }
  return factory
}
